home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Frameworks / TransSkel 3.24 / Demos / Pascal Demos / Button / Modal1.p < prev    next >
Text File  |  1996-01-24  |  2KB  |  79 lines

  1. unit Modal1;
  2.  
  3. interface
  4.  
  5.     uses
  6.         Types, QuickDraw, Windows, Dialogs, OSUtils, ButtonGlobals, TransSkel;
  7.  
  8.  
  9.     procedure DoModal1;
  10.  
  11. implementation
  12.  
  13.     const
  14.  
  15.         iOK = 1;
  16.         iCancel = 2;
  17.         iEditText = 3;
  18.         iOutline = 4;
  19.  
  20.  
  21. {--------------------------------------------------------------------}
  22. { Dialog 1 procedures }
  23. {--------------------------------------------------------------------}
  24.  
  25. procedure DoModal1;
  26. var
  27.     filter: ModalFilterUPP;
  28.     dlog: DialogPtr;
  29.     savePort: GrafPtr;
  30.     item: Integer;
  31.     str: Str255;
  32.     hilite: Integer;
  33.     loop: Boolean;
  34. begin
  35.     dlog := GetNewDialog(modal1Res, nil, WindowPtr(-1));
  36.     if (dlog = DialogPtr(nil)) then
  37.         begin
  38.             SysBeep(1);
  39.             exit(DoModal1);
  40.         end;
  41.  
  42.     SkelPositionWindow(dlog, skelPositionOnMainDevice, horizRatio, vertRatio);
  43.  
  44.     GetPort(savePort);
  45.     SetPort(dlog);
  46.  
  47.     SkelSetDlogButtonOutliner(dlog, iOutline);
  48.     SkelSetDlogStr(dlog, iEditText, 'Default button is active only when this field is non-empty');
  49.     SelectDialogItemText(dlog, iEditText, 0, 32767);
  50.  
  51.     ShowWindow(dlog);
  52.  
  53.     loop := true;
  54.     while (loop) do
  55.         begin
  56.             filter := SkelDlogFilter(nil, true);
  57.             SkelDlogCancelItem(iCancel);
  58.             SkelDlogTracksCursor(true);
  59.             ModalDialog(filter, item);
  60.             SkelRmveDlogFilter;
  61.             if ((item = iOK) or (item = iCancel)) then
  62.                 loop := false
  63.             else
  64.                 begin
  65.                     SkelGetDlogStr(dlog, iEditText, str);
  66.                     if (length(str) > 0) then
  67.                         hilite := normalHilite
  68.                     else
  69.                         hilite := dimHilite;
  70.                     if (SkelSetDlogCtlHilite(dlog, iOK, hilite)) then
  71.                         SkelDrawButtonOutline(SkelGetDlogCtl(dlog, iOK));
  72.                 end;
  73.         end;
  74.  
  75.     DisposeDialog(dlog);
  76.     SetPort(savePort);
  77. end;
  78.  
  79. end.